# 饿汉式单例：程序启动时就创建实例
class SingletonEager:
    # 类加载时就初始化实例
    _instance = None

    # 在类定义时就创建实例
    def __new__(cls):
        if cls._instance is None:
            cls._instance = super().__new__(cls)
        return cls._instance


# 测试
if __name__ == "__main__":
    s1 = SingletonEager()
    s2 = SingletonEager()
    print(f"饿汉式 - s1和s2是否为同一实例: {s1 is s2}")  # 输出 True